/**
 * 项目配置文件
 * 统一管理数据库连接、API地址等配置信息
 */

// 环境配置
const ENV = import.meta.env.MODE || 'development'
const GRAY_MODE = import.meta.env.VITE_GRAY_MODE === 'true' || ENV === 'development'

// 基础配置
const config = {
  // 应用信息
  app: {
    name: 'AI测试平台',
    version: '1.0.0',
    description: '冰酱的AI测试平台'
  },

  // 灰度模式配置
  grayMode: {
    enabled: GRAY_MODE,
    username: 'admin',
    password: '123456',
    description: '灰度模式：简化登录流程'
  },

  // API配置
  api: {
    development: {
      baseURL: import.meta.env.VITE_API_BASE_URL || 'http://localhost:5001',
      timeout: 10000
    },
    production: {
      baseURL: import.meta.env.VITE_API_BASE_URL || 'https://your-production-api.com',
      timeout: 15000
    }
  },

  // 数据库配置（用于后端参考）
  database: {
    development: {
      type: 'mysql',
      host: 'localhost',
      port: 3306,
      user: 'idahan',
      password: 'Hb@123456',
      name: 'aiproject',
      connectionString: 'mysql://idahan:Hb@123456@localhost:3306/aiproject'
    },
    production: {
      type: 'mysql',
      host: 'your-prod-host',
      port: 3306,
      user: 'prod_user',
      password: 'prod_password',
      name: 'aiproject_prod',
      connectionString: 'mysql://prod_user:prod_password@your-prod-host:3306/aiproject_prod'
    }
  },

  // 前端路由配置
  routes: {
    login: '/login',
    main: '/main',
    home: '/home',
    apiManagement: '/api-management'
  },

  // UI配置
  ui: {
    theme: {
      primary: '#8b5cf6',
      secondary: '#06b6d4',
      success: '#10b981',
      warning: '#f59e0b',
      error: '#ef4444'
    },
    layout: {
      sidebarWidth: '280px',
      headerHeight: '64px'
    }
  },

  // 默认用户配置
  defaultUser: {
    username: 'admin',
    password: '12345'
  }
}

// 获取当前环境配置
export const getConfig = () => {
  return {
    ...config,
    api: config.api[ENV],
    database: config.database[ENV]
  }
}

// 导出具体配置
export const API_CONFIG = config.api[ENV]
export const DB_CONFIG = config.database[ENV]
export const APP_CONFIG = config.app
export const UI_CONFIG = config.ui
export const ROUTES_CONFIG = config.routes
export const GRAY_MODE_CONFIG = config.grayMode

export default config